from django.db import models
from django.utils.timezone import now

# Create your models here.
class Genres(models.Model):
    category=models.CharField(max_length=70)
    def __str__(self):
        return self.category

class RPT_Category(models.Model):
    rpt_category=models.CharField(max_length=70)

    def __str__(self):
        return self.rpt_category
class LRT_Catgory(models.Model):
    LRT_category = models.CharField(max_length=70)

    def __str__(self):
        return self.LRT_category


class Pay_more_attention(models.Model):
    degree = models.CharField(max_length=2,default=1)
    def __str__(self):
        return self.degree

class HotTopic(models.Model):
    ishottopic=models.BooleanField(default=False,verbose_name='是否是HotTopic系列的影片')
    def __str__(self):
        if self.ishottopic:
            return 'True'
        else:
            return 'False'

class MovieInfo(models.Model):
    movie_class=models.CharField(max_length=20,default='new')
    movie_name=models.CharField(max_length=70)
    movie_content=models.CharField(max_length=300)
    release_time=models.DateField(default=now)
    movie_image=models.ImageField(upload_to='movie')
    movie_category=models.ManyToManyField(Genres)
    movie_rtpcatgory=models.ManyToManyField(RPT_Category)
    movie_lrtcatgory = models.ManyToManyField(LRT_Catgory)
    movie_degree=models.ForeignKey('Pay_more_attention',on_delete=models.CASCADE,default=None,blank=True)
    movie_hottopic=models.ForeignKey('HotTopic',on_delete=models.CASCADE,default=False,blank=True)

    def __str__(self):
        return self.movie_name


class Movie_recent_visit(models.Model):
    movie_id=models.ForeignKey('MovieInfo',on_delete=models.CASCADE,max_length=5,verbose_name='记录访问过电影的id')
    visit_time=models.DateField(default=now,verbose_name='记录访问时间')









